# coding: utf-8
from sqlalchemy import Column, Date, DateTime, Float, JSON, String
from sqlalchemy.dialects.mysql import INTEGER, MEDIUMBLOB
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()
metadata = Base.metadata



class TbPageBP(Base):
    __tablename__ = 'tb_page_BP'

    user_id = Column(String(50), primary_key=True, nullable=False)
    proj_id = Column(String(50), primary_key=True, nullable=False)
    table_data = Column(String(2000))
    select_model = Column(String(255))
    select_f_name = Column(String(50))
    select_d_name = Column(String(255))
    start_year = Column(String(255))


class TbPageDataBP(Base):
    __tablename__ = 'tb_page_data_BP'

    user_id = Column(String(50), primary_key=True, nullable=False)
    proj_id = Column(String(50), primary_key=True, nullable=False)
    model_name = Column(String(100))
    unit_name = Column(String(100))
    start_end_date = Column(String(100))






class TbUserprojBasic(Base):
    __tablename__ = 'tb_userproj_basic'
    __table_args__ = {'comment': '用户工程信息表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    Proj_Name = Column(String(50), comment='工程名称')
    Proj_CreatDateTime = Column(Date, comment='创建时间')
    Proj_UpdateTime = Column(DateTime, comment='更新时间')
    Remark = Column(String(255), comment='工程说明')


class TbUserprojCurveDatum(Base):
    __tablename__ = 'tb_userproj_curve_data'
    __table_args__ = {'comment': '用户曲线图信息恢复表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    Curve_Data = Column(JSON, comment='曲线图恢复数据')


class TbUserprojDvpunitOilstimevalInput(Base):
    __tablename__ = 'tb_userproj_dvpunit_oilstimeval_input'
    __table_args__ = {'comment': '用户工程单元经济评价计算功能输入数据表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    InputData = Column(JSON, comment='数据')


class TbUserprojDvpunitOilstimevalOut(Base):
    __tablename__ = 'tb_userproj_dvpunit_oilstimeval_out'
    __table_args__ = {'comment': '用户工程单元经济评价计算功能输出结果表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    OutputData = Column(JSON, comment='数据')


class TbUserprojModelUiset(Base):
    __tablename__ = 'tb_userproj_model_uiset'
    __table_args__ = {'comment': '用户工程功能界面设置表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    Model_UiID = Column(String(30), primary_key=True, nullable=False, comment='功能界面ID')
    Ui_Set = Column(JSON, nullable=False, comment='界面参数设置,JSON格式存储用户工程')


class TbUserprojOilstimeval(Base):
    __tablename__ = 'tb_userproj_oilstimeval'
    __table_args__ = {'comment': '计算表格数据恢复表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    Data = Column(JSON, comment='恢复数据')


class TbUserprojPage1(Base):
    __tablename__ = 'tb_userproj_page1'
    __table_args__ = {'comment': '第一页面相关数据表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    Page_data = Column(JSON, comment='界面表格数据')
    Fliter_data = Column(JSON, comment='界面筛选信息')
    Set_info = Column(JSON, comment='界面设置')
    Picture1 = Column(MEDIUMBLOB, comment='图片1')
    Picture2 = Column(MEDIUMBLOB, comment='图片2')
    Picture3 = Column(MEDIUMBLOB, comment='图片3')
    Ramake = Column(String(255), comment='说明')


class TbUserprojPage2(Base):
    __tablename__ = 'tb_userproj_page2'
    __table_args__ = {'comment': '第二页面相关数据表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    Page_data = Column(JSON, comment='界面表格数据')
    Fliter_data = Column(JSON, comment='界面筛选信息')
    Set_info = Column(JSON, comment='界面设置')
    Picture1 = Column(MEDIUMBLOB, comment='图片1')
    Picture2 = Column(MEDIUMBLOB, comment='图片2')
    Picture3 = Column(MEDIUMBLOB, comment='图片3')
    Ramake = Column(String(255), comment='说明')


class TbUserprojPage3(Base):
    __tablename__ = 'tb_userproj_page3'
    __table_args__ = {'comment': '第三页面相关数据表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    Page_data = Column(JSON, comment='界面表格数据')
    Fliter_data = Column(JSON, comment='界面筛选信息')
    Set_info = Column(JSON, comment='界面设置')
    Picture1 = Column(MEDIUMBLOB, comment='图片1')
    Picture2 = Column(MEDIUMBLOB, comment='图片2')
    Picture3 = Column(MEDIUMBLOB, comment='图片3')
    Ramake = Column(String(255), comment='说明')


class TbUserprojShareset(Base):
    __tablename__ = 'tb_userproj_shareset'
    __table_args__ = {'comment': '用户工程共享设置表'}

    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    Proj_Name = Column(String(30), nullable=False, comment='工程名称')
    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    User_Name = Column(String(30), nullable=False, comment='用户名称')
    ProjShared_User = Column(String(300), primary_key=True, nullable=False, comment='共享用户')
    ProjShared_PermitType = Column(String(30), comment='共享权限;只有“只读”、“可另存”、“无”三种权限')
    Remark = Column(String(200), comment='备注')


class TbYearProfitLossAn(Base):
    __tablename__ = 'tb_year_profit_loss_ans'
    user_id = Column(String(200), primary_key=True, nullable=False)
    project_id = Column(String(200), primary_key=True, nullable=False)
    dvpUnit_Name = Column(String(200))
    stimType_Name = Column(String(200))
    year = Column(String(50))
    well_Name = Column(String(50))
    calcu_type = Column(String(200))
    OilPriceCritical = Column(Float(255))
    IncreOilCritical = Column(Float(255))
    StimCostCritical = Column(Float(255))
    analysis_data = Column(String(255))
    parm_set_data = Column(String(255))
    Stim_ValidPeriod_Average = Column(INTEGER(11), comment='平均有效期')
    Stim_IncreOil_Average = Column(Float(255), comment='平均累计增油量')
    StimOil_CommodityRatio = Column(Float(50), comment='原油商品率')
    Oil_Price = Column(Float(50), comment='原油价格')
    OilSale_TotalTaxRatio = Column(Float(50), comment='销售税费率')
    Money_Discount = Column(Float(50), comment='资金贴现率')
    Oil_OprCost = Column(Float(50), comment='操作吨油成本')
    StimCost_Average = Column(Float(50), comment='平均作业成本')

class TbYearWellProfitLossAn(Base):
    __tablename__ = 'tb_year_well_profit_loss_ans'
    user_id = Column(String(200), primary_key=True, nullable=False)
    project_id = Column(String(200), primary_key=True, nullable=False)
    DvpUnit_OilStim_PlanProj_Name = Column(String(30), comment='规划方案')
    Forecast_Method = Column(String(100), comment='预测方法')
    dvpUnit_Name = Column(String(200))
    stimType_Name = Column(String(200))
    year = Column(String(50))
    well_Name = Column(String(50))
    calcu_type = Column(String(200))
    OilPriceCritical = Column(Float(255))
    IncreOilCritical = Column(Float(255))
    StimCostCritical = Column(Float(255))
    analysis_data = Column(String(255))
    parm_set_data = Column(String(255))
    Stim_ValidPeriod_Average = Column(INTEGER(11), comment='平均有效期')
    Stim_IncreOil_Average = Column(Float(255), comment='平均累计增油量')
    StimOil_CommodityRatio = Column(Float(50), comment='原油商品率')
    Oil_Price = Column(Float(50), comment='原油价格')
    OilSale_TotalTaxRatio = Column(Float(50), comment='销售税费率')
    Money_Discount = Column(Float(50), comment='资金贴现率')
    Oil_OprCost = Column(Float(50), comment='操作吨油成本')
    StimCost_Average = Column(Float(50), comment='平均作业成本')

class TbYearDvpUnitProfitLossAn(Base):
    __tablename__ = 'tb_year_dvpUnit_profit_loss_ans'

    user_id = Column(String(200), primary_key=True, nullable=False)
    project_id = Column(String(200), primary_key=True, nullable=False)
    DvpUnit_OilStim_PlanProj_Name = Column(String(30), comment='规划方案')
    Forecast_Method = Column(String(100), comment='预测方法')
    dvpUnit_Name = Column(String(200))
    stimType_Name = Column(String(200))
    year = Column(INTEGER(200))
    calcu_type = Column(String(200))
    OilPriceCritical = Column(Float(255))
    IncreOilCritical = Column(Float(255))
    StimCostCritical = Column(Float(255))
    analysis_data = Column(String(255))
    parm_set_data = Column(String(255))
    Stim_WellNumber_Valid = Column(INTEGER(11), comment='有效井次')
    Stim_WellValidRatio = Column(Float(50), comment='有效率')
    Stim_ValidPeriod_Average = Column(INTEGER(11), comment='平均有效期')
    Stim_IncreOil_Average = Column(Float(255), comment='平均累计增油量')
    StimOil_CommodityRatio = Column(Float(50), comment='原油商品率')
    Oil_Price = Column(Float(50), comment='原油价格')
    OilSale_TotalTaxRatio = Column(Float(50), comment='销售税费率')
    Money_Discount = Column(Float(50), comment='资金贴现率')
    Oil_OprCost = Column(Float(50), comment='操作吨油成本')
    StimCost_Average = Column(Float(50), comment='平均作业成本')

class TbUserprojWellInput(Base):
    __tablename__ = 'tb_userproj_well_input'
    __table_args__ = {'comment': '用户工程输入表'}

    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    InputData = Column(JSON, comment='数据')

class TbUserprojWellOut(Base):
    __tablename__ = 'tb_userproj_well_out'
    __table_args__ = {'comment': '用户工程输出表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    OutputData = Column(JSON, comment='数据')

class TbYearOilstimPlanprojStimevalCalInput(Base):
    __tablename__ = 'tb_year_oilStim_planproj_stimeval-cal_input'
    __table_args__ = {'comment': '输入表'}

    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    DvpUnit_Name = Column(String(200), primary_key=True, nullable=False, comment='井号')
    Year = Column(Date, primary_key=True, nullable=False, comment='日期')
    StimType_Name = Column(String(200), primary_key=True, nullable=False, comment='措施类别')
    Forecast_Method = Column(String(30), comment='预测方法')
    Stim_WellValidRadio = Column(Float(10), comment='有效率')
    Stim_WellNumber_Valid = Column(Float(10), comment='有效井次')
    Stim_ValidPeriod_Average = Column(Float(10), comment='平均有效期')
    Stim_IncreOil_Average = Column(Float(10), comment='平均增油量')
    Update_Date = Column(DateTime, comment='更新时间')
    Stim_Cost = Column(Float(10), comment='预测作业费用')
    Oil_CommodityRatio = Column(Float(10), comment='原油商品率')
    Oil_Price = Column(Float(10), comment='原油价格')
    Monet_Discount = Column(Float(10), comment='资金贴现率')
    Remark = Column(String(200), comment='备注')

class TbYearOilstimPlanprojStimevalCalOutput(Base):
    __tablename__ = 'tb_year_oilStim_planproj_stimeval-cal_output'
    __table_args__ = {'comment': '输出表'}

    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    DvpUnit_OilStim_PlanProj_Name = Column(String(200), primary_key=True, nullable=False, comment='井号')
    DvpUnit_Name = Column(String(200), primary_key=True, nullable=False, comment='井号')
    Year = Column(Date, comment='日期')
    StimType_Name = Column(String(200), comment='措施类别')
    Stim_WellValidRatio = Column(Float(10), comment='有效率')
    Stim_WellNumber_Valid = Column(Float(10), comment='有效井次')
    Stim_ValidPeriod_Average = Column(Float(10), comment='平均有效期')
    Stim_IncreOil_Average = Column(Float(10), comment='平均增油量')
    StimOil_CommodityRatio = Column(Float(10), comment='原油商品率')
    Oil_Price = Column(Float(10), comment='原油价格')
    OilSale_TotalTaxRatio = Column(Float(10), comment='销售税费率')
    Money_Discount = Column(Float(10), comment='资金贴现率')
    Oil_OprCost = Column(Float(10), comment='操作吨油成本')
    StimCost_Average = Column(Float(10), comment='平均作业成本')
    StimOil_WellOprCost_Average = Column(Float(10), comment='平均增油操作成本')
    StimOil_Total_Tax_Average = Column(Float(10), comment='平均销售总税费')
    StimOil_Gross_SalesIncome_Average = Column(Float(10), comment='平均销售毛收入')
    StimOil_Static_Gains_Average = Column(Float(10), comment='平均静态收益')
    StimOil_NPV_Average = Column(Float(10), comment='平均财务净现值')
    StimOil_ROI = Column(Float(10), comment='投资利润率')
    StimOil_NPVR = Column(Float(10), comment='财务净现值率')
    StimOil_FIRR = Column(Float(10), comment='财务内部收益率')
    Stim_IncreOil_Critical_Average = Column(Float(10), comment='平均临界增油量')
    StimOil_Price_Critical = Column(Float(10), comment='增油经济临界油价')
    Remark = Column(String(200), comment='备注')

class TbUserprojWellCaldata(Base):
    __tablename__ = 'tb_userproj_well_caldata'
    __table_args__ = {'comment': '油井计算输出表'}

    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    WellCal_Data = Column(JSON, comment='曲线图恢复数据')

class TbOilStimPlanProjWellCalInput(Base):
    __tablename__ = 'tb_OilStim_PlanProj_Well_Cal_Input'
    __table_args__ = {'comment': '单井输入表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    InputData = Column(JSON, comment='数据')

class TbOilStimPlanProjWellCalOutput(Base):
    __tablename__ = 'tb_OilStim_PlanProj_Well_Cal_Output'
    __table_args__ = {'comment': '单井输出表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    OutputData = Column(JSON, comment='数据')

class TbOilStimPlanProjWellCalData(Base):
    __tablename__ = 'tb_OilStim_PlanProj_Well_Cal_Data'
    __table_args__ = {'comment': '预测油井计算表'}

    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Plan_Well_Data = Column(JSON, comment='预测数据')

class TbUnitSchemeCurveDataRecovery(Base):
    __tablename__ = 'tb_unit_scheme_curve_data_recovery'
    __table_args__ = {'comment': '单元方案曲线数据恢复表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    Data = Column(JSON, comment='数据')

class TbOilStimPlanProjUnitCalData(Base):
    __tablename__ = 'tb_oilStim_PlanProj_Unit_Cal_Data'
    __table_args__ = {'comment': '表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    Data = Column(JSON, comment='数据')

class TbOilStimPlanProjUnitCalInputData(Base):
    __tablename__ = 'tb_oilStim_PlanProj_Unit_Cal_InputData'
    __table_args__ = {'comment': '表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    Input = Column(JSON, comment='数据')

class TbOilStimPlanProjUnitCalOutputData(Base):
    __tablename__ = 'tb_oilStim_PlanProj_Unit_Cal_OutputData'
    __table_args__ = {'comment': '表'}

    User_ID = Column(String(30), primary_key=True, nullable=False, comment='用户ID')
    Proj_ID = Column(String(30), primary_key=True, nullable=False, comment='工程ID')
    Output = Column(JSON, comment='数据')